#!/bin/bash
if [ "$1" == "" ];then
	echo "please input correct compile arch name; aarch64 mips64 loongarch64 x86-64"
	exit
fi
#go version1.22.4
ARCH=$1
BUILDNAME=
BUILDARCH=
if [ $ARCH == "aarch64" ];then 
	BUILDARCH=arm64
	BUILDNAME=xinke-ftpserver-arm64
elif [ $ARCH == "mips64" ];then
	BUILDARCH=mips64le
	BUILDNAME=xinke-ftpserver-mips64le       
elif [ $ARCH = "loongarch64" ];then
	BUILDARCH=loong64
	BUILDNAME=xinke-ftpserver-loongarch64 
elif [ $ARCH = "x86-64" ];then
	BUILDARCH=amd64
	BUILDNAME=xinke-ftpserver-amd64  
else
	echo "please input correct compile arch name; aarch64 mips64 loongarch64 x86-64"
	exit
fi
GO_PATH=$PWD/go/bin
echo "build arch: "${BUILDARCH}
echo "build name: "${BUILDNAME}
echo "go path: "${GO_PATH}

export GOOS=linux
export GOARCH=${BUILDARCH}
export GO111MODULE=on
export CGO_ENABLE=0
export PATH=${GO_PATH}:$PATH

go version
go env -w GOPROXY=https://goproxy.cn

cd xinke-ftpserver

go build -o ${BUILDNAME}

echo  "build over"


